﻿using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SYT.AliApiHandle.SubmitToAli
{
    public class SubmitUpdateToAli
    {
        public static string UpdateTitle(string offerId, string subject, string access_token)
        {
            string apiUrl = "https://gw.open.1688.com/openapi/param2/1/com.alibaba.product/alibaba.product.incrementModify";

            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("access_token", access_token);
            dic.Add("productID", offerId);
            dic.Add("subject", subject);
            dic.Add("webSite", "1688");

            string jsonStr = ApiHelp.RunHttps(apiUrl, dic, access_token, "post");
            Hashtable hs = (Hashtable)PluSoft.Utils.JSON.Decode(jsonStr);
            Hashtable hsb = hs["result"] != null ? (Hashtable)hs["result"] : new Hashtable();
            string productID = hsb["productID"] != null ? hsb["productID"].ToString() : "";
            if (productID == offerId) return "true";
            else return "false";
        }
    }
}
